package com.example.managesystem.mapper;

import com.example.managesystem.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {

    /**
     * 根据用户id查询数据
     * @param userid
     * @return
     */
    @Select("select * from user where userid = #{userid}")
    public User getByUserId(String userid);

    /**
     * 修改密码
     * @param userid
     * @param newPassword
     */
    /*@Update("update user set password = #{newPassword} where userid = #{userid}")*/
    void updatePassword(@Param("userid")String userid,  @Param("newPassword") String newPassword);

    /**
     * 根据id查询用户
     * @param id
     */
    @Select("select userid from user where id = #{id}")
    String getById(@Param("id") Integer id);


    @Update("update user set name = #{user1.name},dept = #{user1.dept},major = #{user1.major},phone = #{user1.phone} where userid = #{user1.userid}")
    void updateMessage(@Param("user1") User user1);

    @Select("select name from user where userid = #{prinuserid}")
    String getNameByUserId(String prinuserid);
}
